package cn.training.service;

import java.util.List;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.training.bean.UserBean;

@Service
public class HelloWorldService {

	@Autowired
	QueryDAO queryDao;

	@Autowired
	UpdateDAO updateDao;

	
	public List<UserBean> searchUserss(UserBean frm) {
		List<UserBean> result=queryDao.executeForObjectList("User.selectUsers",frm);
		return result;
	}
	public int deleteUser(UserBean frm) {
		int result=updateDao.execute("User.deleteUser",frm);
		return result;
	}
	public UserBean searchUser(UserBean frm) {
		UserBean  result=queryDao.executeForObject("User.selectUser",frm,UserBean.class);
		return result;
	}
	public UserBean searchUser2(UserBean frm) {
		UserBean  result=queryDao.executeForObject("User.selectUser2",frm,UserBean.class);
		return result;
	}
	public List<UserBean> searchUsers() {
		List<UserBean>  result=queryDao.executeForObjectList("User.selectUsers",null);
		return result;
	}
	public int updateUser(UserBean frm) {
		int result=updateDao.execute("User.updateUser",frm);
		return result;
	}
	
	
	public int insert(UserBean frm) {
		int result=0;
		try{
			result=updateDao.execute("User.userInsert",frm);
			}
		catch(Exception e){
		result=888;}
				
		return result;
	}
		
	public int searchdelete(UserBean frm) {
		return	updateDao.execute("User.deleteUser",frm);
		
	}
		
		
	
}
